package com.mz.mattress.client.config;

import com.mz.mattress.client.config.demo.Monkey;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

public class AnimalImportBeanDefinitionRegistrar implements ImportBeanDefinitionRegistrar {

    @Override
    public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {

        boolean bl = registry.containsBeanDefinition("com.mz.mattress.client.config.demo.Cat");
        boolean bl2 = registry.containsBeanDefinition("com.mz.mattress.client.config.demo.Dog");

        if (bl && bl2) {

            RootBeanDefinition root = new RootBeanDefinition(Monkey.class);
            registry.registerBeanDefinition("monkey", root);

        }


    }

}
